<?php

//print_r($_POST);
 
// username and password sent from form 
$result=array();
$start = microtime(true);
$result['start']=$start;
if(!isset($_POST['ip'])||!isset($_POST['os'])||!isset($_POST['browser'])||!isset($_POST['id'])){
	//header("location:../index.php?page=contact_user&stat=error");
	$action="home_stat";
$ip="192.168.1.1";
$os="Windows Vista 64位";
$browser="Chrome";
$id="1";
}else{
	$id=$_POST['id'];
	$ip=$_POST['ip'];
	$os=$_POST['os'];
	$browser=$_POST['browser'];
}
	
$sql="UPDATE `user` SET ip='$ip',os='$os',browser='$browser' WHERE id='$id'";




$qr = mysql_query( $sql ) or die( mysql_error() );
if($qr){
	$sql="select password,browser from user where id ='$id'";
	$sqlresult = mysql_query( $sql ) or die( mysql_error() );

	
	if(!$sqlresult){

	  $result['server_latency'] = microtime(true) - $start;
	  $result['sql_failure']=1;
	  echo json_encode($result);
	  return;
	}
	$row = mysql_fetch_array($sqlresult);
		$password=$row['password'];
		$browser=$row['browser'];
		
	$error=array();
	$a = strstr($browser, 'Internet');
	if($a!=""){
		array_push($error,"不推荐用此浏览器，请尽快下载谷歌或者火狐最新版本");
	}

	if($password=='1111'){
		array_push($error,"初始密码还未更改请尽快更改");
	}
	$end = microtime(true);
	$result['error'] = $error;
	$result['server_latency'] = $end- $start;
	$result['sql_failure']=0;
	$result['end']=$end;
	
	  echo json_encode($result);
	  return;
	
}else{
	$result['server_latency'] = microtime(true) - $start;
	$result['sql_failure']=1;
	  echo json_encode($result);
	  return;
}



?>